package 常用类.Array类.collections;

import 面向对象中级.访问权限修饰符.A;

import java.util.*;

public class CollectionsDome {
    public static void main(String[] args) {
        //创建ArrayList对象
        List<Integer> list=new ArrayList<>();
        list.add(90);
        list.add(54);
        list.add(100);
        list.add(54);
        list.add(54);
        list.add(26);

        //排序再反转（倒序排序）
        Collections.sort(list,Collections.reverseOrder());
        System.out.println(list);
        //填充列表中所有元素为指定值
        Collections.fill(list,88);
        System.out.println(list);

        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer integer1, Integer integer2) {
                return integer2-integer1;
            }
        });
        System.out.println(list);

        //基于二分查找算法的搜索实现(二分查找必须有序)
        int index=Collections.binarySearch(list,54);
        System.out.println(index);

        int[] nums=new int[10];
        Arrays.fill(nums,-1);
        System.out.println(Arrays.toString(nums));
    }
}
